/* tisa.h */

#ifndef __TISA_H__
#define __TISA_H__ 1

#include <pthread.h>
#include <netinet/in.h>
#include <stdlib.h>

#include "tqueue.h"

#define MAX_SCHED_TASK 3
#define PATH "tisa.log"
#define TS_READ 100
#define TS_TEMP 150
#define TS_LEVEL 200
#define TS_SCREEN 1000

enum {
	Ta = 0,
	T,
	Ti,
	No,
	H,
	Ni,
	Q,
	TREF,
	HREF
};

/* A structure wich contains informations about of the boiler controlled*/
struct boiler {
	int sock_fd;
	int flag;
	struct sockaddr_in server;
	struct tq_elem tqe[MAX_SCHED_TASK];
	float variables[HREF + 1];
	pthread_mutex_t mutex;
	pthread_cond_t cond;
};

/* A structure which contains information on the commands this program. */
struct cmd {
	char *name;
	int (*func) (char *str, struct boiler *heater);
	char *doc;
};

struct tisa_config {
	char *address;
	char *path;
	int port;
};

void terminal(struct boiler *heater);
void control_temp(struct tq_elem *tqe);
void control_level(struct tq_elem *tqe);
void refresh_screen(struct tq_elem *tqe);

#endif /* __TISA_H__ */
